<?php

namespace App\Http\Requests\Admin\Panx\Product;

use App\Http\Requests\ApiRequest;

/**
 * @property array attribute_values
 */
class ProductAttributeUpdateRequest extends ApiRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }
    
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'product_mod_id'         => 'required|int|min:1',
            'name'                     => ['required', 'string', 'min:1'],
            'attribute_values'         => 'required|array',
            'attribute_values.*.id'    => 'required|int|min:0',
            'attribute_values.*.value' => 'required|string|min:1',
        ];
    }
    
    /**
     * @return array
     */
//    public function messages()
//    {
//        return [
//            'product_mod_id.*'   => '商品模型的id必须是数值',
//            'name.*'               => '属性名称必须是字符串',
//            'attribute_values.*'   => '属性值必须是数组',
//            'attribute_values.*.*' => '属性值必须是字符串',
//        ];
//    }
}
